//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.crazy.plugins.gen;

import cn.org.rapid_framework.generator.GeneratorFacade;
import java.io.IOException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;

/**
 * @className PrintTableInfoMojo
 * @description 打印数据库中的表名称
 * @author zhouzhendong
 * @date 2019/7/30 17:18
 * @version V1.0
 */
@Mojo(name = "print")
public class PrintTableInfoMojo extends AbstarctGeneratorMojo {
    private GeneratorFacade g;

    public PrintTableInfoMojo() {
    }

    public void execute() throws MojoExecutionException, MojoFailureException {
        Thread currentThread = Thread.currentThread();
        ClassLoader oldClassLoader = currentThread.getContextClassLoader();

        try {
            currentThread.setContextClassLoader(this.getClassLoader());
            System.out.println("current project to build: " + this.getProject().getName() + "\n" + this.getProject().getFile().getParent());
            this.g = new GeneratorFacade();
            this.g.getGenerator().setTemplateRootDirs(new String[]{"classpath:template"});

            try {
                this.g.deleteOutRootDir();
            } catch (IOException var7) {
                var7.printStackTrace();
            }

            printAllTableNames();
        } finally {
            currentThread.setContextClassLoader(oldClassLoader);
        }

    }

    public static void printAllTableNames() {
        try {
            GeneratorFacade.printAllTableNames();
        } catch (Exception var1) {
            var1.printStackTrace();
        }

    }

    public static void main(String[] args) {
        printAllTableNames();
    }
}
